<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.js"></script>
  </head>
  <body>
    <div id="app">
      <textarea
        name="travels"
        id="travels"
        class="travels"
        @blur="handleInputBlur"
        placeholder="请输入正文..."
        v-model="word"
      ></textarea>
      <span>{{message}}</span>
    </div>

    <script>
      var app = new Vue({
        el: '#app',
        data: {
          message: 'Hello Vue!',
          word: 'word'
        },
        methods: {
          // 输入框失去焦点时的位置
          handleInputBlur(e) {
            this.blurIndex = e.srcElement.selectionStart
            console.log(this.blurIndex);
          }
        }
      })
    </script>
  </body>
</html>
